<#include "../header.ftl" />
<@head title="草稿箱" />
		<@side.sidenav active="草稿箱"/>
	    <div class="g-content">
	        <div class="g-content-container">
	            <div class="g-p">
					<div class="m-crumb">
					    <ul class="f-cb">
					        <li><i>&gt;</i><a href="${spaceUrl}/admin">博客管理</a></li>
					        <li><i>&gt;</i><a href="javascript:void(0);">草稿箱</a></li>
					    </ul>
					</div>
					<div class="page-title">
						<h1>草稿箱</h1>
					</div>
					<div class="m-content">
						<form name="postForm" id="postForm" action="${spaceUrl}/admin/post/list" method="GET">
							<@spring.bind "postPage" />
							<!-- pagination parameter -->
							<@spring.formHiddenInput path="postPage.pageNo" />
							<@spring.formHiddenInput path="postPage.totalPages" />
							<@spring.formHiddenInput path="postPage.totalCount" />
							<!-- sorter parameter -->
							<@spring.formHiddenInput path="postPage.sortEnable" />
							<@spring.formHiddenInput path="postPage.sort.field" />
							<@spring.formHiddenInput path="postPage.sort.order" />
							
						    
					    	<#if (postPage?exists && postPage.result?size > 0)>
					    		<div id="medias" class="sep">
						        	<#list postPage.result as post>
							    		<div class="media">
						        			<div class="media-body">
						        				<div class="media-body-title">
						        					<strong><#if post.isTop><span class="post-top">[置顶]</span></#if><a href="${spaceUrl}/admin/post/edit?id=${post.id}">${post.title}</a>：</strong>
						        					<small class="pull-right">
						        						<a style="color:#ec5524;" href="javascript:deletePost(this, ${post.id});">删除</a>
								    					<a style="color:#ec5524;" href="${spaceUrl}/admin/post/edit?id=${post.id}">修改</a>
						        					</small>
						        				</div>
						        				<p class="typo-p">
						        					<@contentTransform content="${post.content}" removeHtml=true substring=true endIndex=300 />
						        				</p>
						        				<p class="typo-small">
								    				创建时间：${post.createTime}
								    				分类：<#if post.catalog?exists>${post.catalog.name}</#if>
								    				查看：${post.views}&nbsp;&nbsp;&nbsp;&nbsp;
								    			</p>
						        			</div>
						        		</div>
							    	</#list>
						    	</div>
						    <#else>
						    	<a class="listpub" href="${spaceUrl}/admin/post/create" class="sep"><i class="icon-plus"></i><span>&nbsp;暂无文章，点击这里发布文章</span></a>
				        	</#if>
						    <#if (postPage.totalPages > 1)>
		                        <@space.pagenavi pageEntity=postPage baseUrl=spaceUrl + "/admin/post/draft?pageNo=$page$" />
		                    </#if>
						</form>
					</div>
	            </div>
	        </div>
	    </div>
	    <script type="text/javascript">
	    	function deletePost(o, postId){
	    		if(!confirm('确认删除该文章吗？')){
	    			return;
	    		}
	    		$.post('${spaceUrl}/admin/post/delete?id=' + postId, function(){
	    			var pageNo = $('#pageNo').val();
	    			var url = '${spaceUrl}/admin/post/draft';
	    			if(pageNo){
	    				url = url + '?pageNo=' + pageNo;
	    			}
	    			window.location.href = url;
	    		});
	    	}
	    </script>
<#include "../footer.ftl" />